package Tools

import (
	"os/exec"
	"strings"
)

const (
	AC    = "Accepted.AC"
	Wring = "Compile Error"
)

//用来描述执行完编译之后的结果
type iCompileResult struct {
	CompileType string
	Meg         string
}

//启动编译器执行代码
func StartProess(path string, Args []string) iCompileResult {
	print(Args[0])
	cmd := exec.Command(path, Args...)
	da, _ := cmd.CombinedOutput()
	cmd.Wait()
	result := iCompileResult{}
	result.Meg = string(da)

	if strings.Contains(string(da), "错误") || strings.Contains(string(da), "error") || strings.Contains(string(da), "Error") {
		result.CompileType = Wring
	} else {
		result.CompileType = AC
	}
	return result
}
